package com.ggk911.pharmacy_system.mapper;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.ggk911.pharmacy_system.entity.SupplierDrug;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.io.Serializable;

/**
 * 供应商提供药物
 *
 * @author ggk-911
 * @version 1.0 2023/3/9 15:23
 */
@Repository
public interface SupplierDrugMapper extends BaseMapper<SupplierDrug> {
    /**
     * 重写的selectPage方法
     * @param page
     * @param queryWrapper
     * @param <P>
     * @return
     */
    @Select(" SELECT " +
            " supplier_drug.*," +
            " drug_info_type.drug_info_type_id as 'drugInfoType.drugInfoTypeId'," +
            " supplier.supplier_id as 'supplier.supplierId'," +
            " supplier.supplier_name as 'supplier.supplierName'," +
            " supplier.supplier_addr as 'supplier.supplierAddr'," +
            " supplier.supplier_phone as 'supplier.supplierPhone'," +
            " supplier.supplier_email as 'supplier.supplierEmail'," +
            " supplier.supplier_license as 'supplier.supplierLicense'," +
            " supplier.supplier_website as 'supplier.supplierWebsite'," +
            " drug_info.drug_info_id  as 'drugInfo.drugInfoId'," +
            " drug_info.drug_info_name  as 'drugInfo.drugInfoName'," +
            " drug_info.drug_info_alias  as 'drugInfo.drugInfoAlias'," +
            " drug_info.drug_info_strength  as 'drugInfo.drugInfoStrength'," +
            " drug_info.drug_info_indications  as 'drugInfo.drugInfoIndications'," +
            " drug_info.drug_info_adverse_reactions  as 'drugInfo.drugInfoAdverseReactions'," +
            " drug_info.drug_info_interactions  as 'drugInfo.drugInfoInteractions'," +
            " drug_info.drug_info_dosage  as 'drugInfo.drugInfoDosage'," +
            " drug_info.drug_info_specifications  as 'drugInfo.drugInfoSpecifications'," +
            " drug_info.drug_info_storage_method  as 'drugInfo.drugInfoStorageMethod'," +
            " drug_info.drug_info_valid_time  as 'drugInfo.drugInfoValidTime'," +
            " drug_info.drug_info_manufacturer  as 'drugInfo.drugInfoManufacturer'," +
            " drug_info.drug_info_national_code  as 'drugInfo.drugInfoNationalCode'," +
            " drug_info.drug_info_approval_no  as 'drugInfo.drugInfoApprovalNo'," +
            " drug_info.drug_info_listing_license_holder  as 'drugInfo.drugInfoListingLicenseHolder'," +
            " drug_info_type.drug_info_type_id as 'drugInfoTypeId'," +
            " drug_info_type.drug_info_type_id as 'drugInfo.drugInfoType.drugInfoTypeId'," +
            " drug_info_type.drug_info_type_name as 'drugInfo.drugInfoType.drugInfoTypeName'" +
            " FROM " +
            " supplier_drug " +
            " LEFT JOIN supplier USING(supplier_id )" +
            " LEFT JOIN drug_info USING(drug_info_id) " +
            " LEFT JOIN drug_info_type USING(drug_info_type_id) " +
            "${ew.customSqlSegment} ")
    <P extends IPage<SupplierDrug>> P selectPage2(P page, @Param("ew") Wrapper<SupplierDrug> queryWrapper);

    /**
     * 增强查询
     * @param id
     * @return
     */
    SupplierDrug selectByIdAd(Integer id);
}
